var currentPage=1;

loadMyEssay();



function tongdunbaocun(){
	var tongdunfen = $("#tongdunfenshu").val();
	$.ajax({ 
		url: urlcore + "/api/mobileAuthentication/tongdunChange?tongdunfen="+tongdunfen,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			alert("保存成功");
		},
		error:function() {
			alert("error");
		}
	});
}


function moneybaocun(){
	var minMoeny = $("#minMoeny").val();
	var maxMoney = $("#maxMoney").val();
	$.ajax({ 
		url: urlcore + "/api/mobileAuthentication/moneybaocun?minMoney="+minMoeny+"&maxMoney="+maxMoney,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			alert("保存成功");
		},
		error:function() {
			alert("error");
		}
	});
}


$(function(){ 
	$.ajax({ 
		url: urlcore + "/api/mobileAuthentication/selectAll?",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			$("#tongdunfenshu").attr("value",data.data.tongdun_score);
			$("#minMoeny").attr("value",data.data.minMoney);
			$("#maxMoney").attr("value",data.data.maxMoney);
		},
		error:function() {
			alert("error");
		}
	}); 

});

function addRefuseArea(){
	var areaName = $("#areaName").val();
	$.ajax({ 
		url: urlcore + "/api/loanOrder/addRefuseArea?areaName="+areaName,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			alert("保存成功");
			window.location.reload(); 
		},
		error:function() {
			alert("error");
		}
	}); 
}
function loadMyEssay(gmtDatetime,name,phoneNumber){
	
	$(document).ready(function() {
		init(currentPage);
	});

	function init(pageNo) {
		$("#thislist").html("");
		$.ajax({
			url: urlcore + "/api/loanOrder/selectRefuseArea?&current=" + pageNo,
			type: "get",
			dataType: 'json',
			async:'false',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
        	if(data.success == true) {
					$.each(data.data.list, function(i, n) {
						var thislist =
							'<tr class="footable-even" style="display: table-row;">' +
							'<td class="footable-visible"><input type="checkbox" /></td>' +
							'<td class="footable-visible">' + n.areaCode + '</td>' +
							'<td class="footable-visible">' + n.areaName + '</td>' +
							'<td class="footable-visible footable-last-column">'+
								'<a  name="删除1"  href="javascript:;"  onclick="delectRefuseArea(' + n.id + ');">删除</a>'+
								'</td>' +
							'</tr>';
							//alert(n.userId);
						$('#thislist').append(thislist);
						
					});
					$.each(arrayTitle, function(i,k) {
						$('a[name="'+k+'"]').attr("hidden",false).attr("class","btn btn-primary btn-xs");
					});
					$("#pager1").pager({
						pagenumber: pageNo,
						pagecount: data.data.pages,
						totalcount: data.data.total,
						buttonClickCallback: PageClick
					});
				

			      if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;

					if(thisUrl.indexOf('login.html') <= -1) {
						top.window.location.href = "login.html";
					}

				} else {
					if(data.msg != '空数据') {
						//alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
				
				}

			},
			error: function() {
				alert("error");
			}
		});
	}
	PageClick = function(pageclickednumber) {
		init(pageclickednumber);
	}

}

function delectRefuseArea(id){
	$.ajax({ 
		url: urlcore + "/api/loanOrder/deleteRefuseArea?id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			window.location.reload(); 
		},
		error:function() {
			alert("error");
		}
	}); 
}